<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <title>选择用户-根据权限</title>
    <link rel="stylesheet" href="${ctx}/assets/admin/LingUI/css/ui.jqgrid.css"/>
    <%@ include file="/include/openstyles.jsp" %>
    <style>
        .help-block {
            margin: 0px !important;
        }
    </style>
</head>
<body>
<div class="row" style="padding: 10px">
    <div class="col-xs-12">
        <div id="search"></div>
        <%--查询条件更多 --%>
        <div class="b_grid_line  col-lg-12"></div>                        <!-- 分隔线 -->
        <table id="user_list_table" class="grid-table"></table>
        <%--jqgrid数据表格 --%>
        <div id="user_list_pager"></div>
        <%--jqgrid表格 页脚 --%>
    </div>
</div>
<script type="text/javascript">
    var scripts = [null,
        "${ctx}/assets/admin/LingUI/js/jqGrid/jquery.jqGrid.js",
        "${ctx}/assets/admin/LingUI/js/jqGrid/i18n/grid.locale-cn.js",
        "${ctx}/assets/admin/LingUI/js/control.js",
        "${ctx}/assets/admin/LingUI/js/jsutil/js/jquery.filterSearch.js",   //筛选搜索
        "${ctx}/assets/admin/pagejs/common.js",
        null];
    var _grid_id = "#user_list_table";	//表格 选择器
    var _pager_id = "#user_list_pager";	//表格页脚 选择器
    ace.load_ajax_scripts(scripts, function () {
        $("#search").strongFilterSearch({
            inputFiled: "USER_ID",				//搜索字段，不填默认为searchValue
            inputPlaceholder: "请输入用户账号",		//占位符
            searchCallback: callback//,				//搜索按钮点击后回调
        });
        //搜索回调函数
        function callback(data) {
            jQuery("#user_list_table").jqGrid('setGridParam', {
                url: "${ctx}/${frameworkPath}/user/index-permission?dataType=${param.dataType}",
                mtype: "POST",
                postData: data //传递的数据
            }).trigger("reloadGrid");
        }


        //调整以适应页面大小  其中 $(".page-content") 为jqgrid的父级容器
        $(window).off('resize.jqGrid').on('resize.jqGrid', function () {
            setTimeout(function () {
                $(_grid_id).jqGrid("setGridWidth", $(".page-content").width());
                $(".ui-jqgrid-bdiv").width($(".page-content").width() + 1);
            }, 50);
        });
        jQuery(_grid_id).jqGrid({
            mtype: "POST",
            url: "${ctx}/${frameworkPath}/user/index-permission?dataType=${param.dataType}",
            colNames: ['账号', '姓名', '邮箱', '邮编', '所属岗位'],
            colModel: [
                {name: 'username', index: 'username', key: true, width: 30, hidden: false},
                {name: 'name', index: 'name', width: 50},
                {name: 'email', index: 'email', width: 80, align: 'left'},
                {name: 'post', index: 'post', width: 40, align: 'left'},
                {name: 'positionname', index: 'positionname', width: 40, align: 'left'}
            ],
            pager: _pager_id, //分页信息 放置的位置
            page: lui.pageNum(_grid_id)
        });
        //自定义工具栏 =============BEGIN======================//
        jQuery(_grid_id).jqGrid('navGrid', _pager_id)
    });

    function getUser() {
        var retObj = new Object();
        var ids = $("#user_list_table").jqGrid('getGridParam', 'selarrrow');
        if (ids.length < 1) {
            lui.warn('至少选择一行数据');
            return;
        }
        else if (ids.length > 1) {
            lui.warn("最多选择一行数据");
            return;
        }
        var rowData = $('#user_list_table').jqGrid('getRowData', ids[0]);
        retObj.state = true;
        retObj.user = rowData.username;
        retObj.name = rowData.name;

        return retObj;
    }
</script>
</body>
</html>